"use strict";
const common_vendor = require("../../common/vendor.js");
const api_index = require("../../api/index.js");
const utils_message = require("../../utils/message.js");
require("../../utils/request.js");
const _sfc_main = {
  __name: "index",
  setup(__props) {
    const bannerList = common_vendor.ref([]);
    const recommended = common_vendor.ref([]);
    const theChartsList = common_vendor.ref([]);
    const getBannerListMethod = async () => {
      try {
        let result = await api_index.indexApi.reqBannerList();
        if (result.code === 200) {
          bannerList.value = result.banners;
        }
      } catch (error) {
        console.log(error);
        utils_message.showToast("获取数据失败", "error");
      }
    };
    const getRecommended = async () => {
      try {
        let result = await api_index.indexApi.reqRecommended();
        if (result.code === 200) {
          recommended.value = result.result;
        }
      } catch (error) {
        utils_message.showToast("获取推荐失败", "error");
      }
    };
    const getTheCharts = async () => {
      try {
        for (let i = 0; i < 5; i++) {
          let result = await api_index.indexApi.reqtheCharts({ idx: i });
          theChartsList.value.push(result.playlist);
        }
      } catch (error) {
        utils_message.showToast("获取排行失败", "error");
      }
    };
    common_vendor.onLoad(() => {
      getBannerListMethod();
      getRecommended();
      getTheCharts();
    });
    return (_ctx, _cache) => {
      return {
        a: common_vendor.f(bannerList.value, (banner, k0, i0) => {
          return {
            a: banner.pic,
            b: banner.bannerId
          };
        }),
        b: common_vendor.f(recommended.value, (remed, k0, i0) => {
          return {
            a: remed.picUrl,
            b: common_vendor.t(remed.name),
            c: remed.id
          };
        }),
        c: common_vendor.o((...args) => _ctx.scroll && _ctx.scroll(...args)),
        d: common_vendor.f(theChartsList.value, (item, k0, i0) => {
          return {
            a: common_vendor.t(item.name),
            b: common_vendor.f(item.tracks, (list, index, i1) => {
              return common_vendor.e({
                a: index < 3
              }, index < 3 ? {
                b: list.al.picUrl
              } : {}, {
                c: index < 3
              }, index < 3 ? {
                d: common_vendor.t(index + 1),
                e: common_vendor.t(list.al.name)
              } : {}, {
                f: index
              });
            }),
            c: item.id
          };
        })
      };
    };
  }
};
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-83a5a03c"], ["__file", "D:/Desktop/cloud_yy/src/pages/index/index.vue"]]);
wx.createPage(MiniProgramPage);
